<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">

        <el-col :span="8">
            <el-form-item label="设备商">
              <el-select v-model="dataForm.FPARENTNO" placeholder="请选择">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="仓库名称">
              <el-select v-model="dataForm.FLEVEL" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="设备类型">
              <el-select v-model="dataForm.FCLASS" placeholder="请选择">
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
          <el-form-item label="设备名称" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"  />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="设备品牌" prop="FACCNO">
            <el-input v-model="dataForm.FACCNO"  />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="设备型号" prop="FSERNO">
            <el-input v-model="dataForm.FSERNO"  />
          </el-form-item>
        </el-col>

        
        <el-col :span="5">
          <el-form-item label="">
            <!-- <el-button type="success" icon="el-icon-plus" @click="insert">添加一行</el-button> -->
            <!-- <el-button type="primary" @click="DlvCreate" :loading="loading" v-if="insertorupdate">保存</el-button> -->
            <el-button type="primary" @click="insert">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <el-table :data="list" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" width="85"></el-table-column>
      <el-table-column prop="FTYPE" label="设备类型" ></el-table-column>
      <el-table-column prop="FNUM" label="固定资产码"></el-table-column>
      <el-table-column prop="FCATNO" label="设备序列号" ></el-table-column>
      <el-table-column prop="FCATNAME" label="设备名称" ></el-table-column>
      <el-table-column prop="FBRAND" label="设备品牌" ></el-table-column>
      <el-table-column prop="FSPEC" label="设备型号" ></el-table-column>
    </el-table>

    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  //import ShopqueryFcuston from "@/components/ShopqueryFcuston/ShopqueryFcuston.vue"
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FPARENTNO:"广州福兴实验室设备科技",
          FLEVEL:"宁波仓库",
          FCLASS:"手环",
          FCATNAME:"智能迷你手环",
          FACCNO:"TFG240101",
          FSERNO:"XH12306",
          FBILLCREDATE:"2024-11-02",
          FMANDATE:"",
          FBILLSTATE:"工作",
          FRMONEY:"5000",
          FDISTYPE:"",
          FUMONEY:"0",
          FLRATE:"100%",
          FLMONEY:"5000",
          FMRKDATE:"2033-11-02",
          FMAC:"",
          FLABEL:"",
          FCOLOR:"",
          FTCP:"",
          FPORT:"",
          FUSEFLAG:"可以",
          FURL:""
        },
        rules: {
          FCATNAME: [
            { required: true, message: '请输入设备名称', trigger: 'blur' },
          ],
          FACCNO: [
            { required: true, message: '请输入固定资产码', trigger: 'blur' },
          ],
          FSERNO: [
            { required: true, message: '请输入设备序号', trigger: 'blur' },
          ],
        },
        list: [],
        loading: false,
        visible: false,

        //所属教学楼选择数据
        options1: [{
          value: '20E01',
          label: '第一教学楼'
        }, {
          value: '20E02',
          label: '第二教学楼'
        }, {
          value: '20N01',
          label: '化学楼'
        }, {
          value: '20N02',
          label: '综合实验楼'
        }],

        //所属楼层选择数据
        options2: [{
          value: '20E01',
          label: '一楼'
        }, {
          value: '20E02',
          label: '二楼'
        }, {
          value: '20N01',
          label: '三楼'
        }, {
          value: '20N02',
          label: '四楼'
        }],

        options4: [{
          value: 'L001',
          label: '在库'
        }, {
          value: 'L002',
          label: '工作'
        }, {
          value: 'L003',
          label: '维护'
        }, {
          value: 'L004',
          label: '保养'
        }, {
          value: 'L005',
          label: '故障'
        }, {
          value: 'L006',
          label: '维修'
        }, {
          value: 'L007',
          label: '报废'
        }],

        options5: [{
          value: '1',
          label: '可以'
        }, {
          value: '2',
          label: '不可'
        }],

        options6: [{
          value: '1',
          label: '平均年限法'
        }, {
          value: '2',
          label: '不计提价法'
        }],

        list: [{  "FENTRYID":1,
                  "FTYPE": "手环",
                  "FNUM":"2412080000008",
                  "FCATNO":"XL-89-23981",
                  "FCATNAME": "智能迷你手环",
                  "FBRAND":"迷你",
                  "FSPEC":"Gv100",
                  "FQTY": "1",
                  "FUNIT": "台",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FTYPE": "手环",
                  "FNUM":"2411300000028",
                  "FCATNO":"TP-77-23981",
                  "FCATNAME": "智能迷你手环",
                  "FBRAND":"迷你",
                  "FSPEC":"TP090",
                  "FQTY": "1",
                  "FUNIT": "台",
                  "FMEMO": ""
                },
                { "FENTRYID":3,
                  "FTYPE": "手环",
                  "FNUM":"2411300000038",
                  "FCATNO":"TP-77-23931",
                  "FCATNAME": "智能迷你手环",
                  "FBRAND":"迷你",
                  "FSPEC":"TP090",
                  "FQTY": "1",
                  "FUNIT": "台",
                  "FMEMO": ""
                },
                { "FENTRYID":4,
                  "FTYPE": "手环",
                  "FNUM":"2411300000048",
                  "FCATNO":"TP-77-23941",
                  "FCATNAME": "智能迷你手环",
                  "FBRAND":"迷你",
                  "FSPEC":"TP090",
                  "FQTY": "1",
                  "FUNIT": "台",
                  "FMEMO": ""
                },
                { "FENTRYID":5,
                  "FTYPE": "手环",
                  "FNUM":"2411300000058",
                  "FCATNO":"TP-77-23951",
                  "FCATNAME": "智能迷你手环",
                  "FBRAND":"迷你",
                  "FSPEC":"TP090",
                  "FQTY": "1",
                  "FUNIT": "台",
                  "FMEMO": ""
                }],

      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        //this.$refs.StudqueryFcuston.open();
        this.visible=false;
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>